import { createStore } from 'vuex'
import createVuexAlong from 'vuex-along'
import auth from './modules/auth'
import scoring from './modules/scoring'

export default createStore({
  state: {
    sidebarCollapsed: false
  },
  mutations: {
    TOGGLE_SIDEBAR(state) {
      state.sidebarCollapsed = !state.sidebarCollapsed
    }
  },
  actions: {
    toggleSidebar({ commit }) {
      commit('TOGGLE_SIDEBAR')
    }
  },
  modules: {
    auth,
    scoring
  },
  plugins: [
    createVuexAlong({
      name: 'endo_sight_uc',
      local: {
        // 只存储必要的认证信息，避免存储大对象
        list: ['auth.token'],
        isFilter: true
      },
      session: {
        list: [],
        isFilter: true
      }
    })
  ]
})